# Copyright © Los Alamos National Security, LLC, and others.

QUACBASE := $(abspath $(shell dirname $(lastword $(MAKEFILE_LIST)))/..)
export PATH := $(QUACBASE)/bin:$(PATH)

.ONESHELL:
.SHELLFLAGS = -ec

## Files

# Directory containing pagecount files
pagecount_dir := raw

# Pagecounts files -- all 50,000+ of them.
pagecount_files := $(pagecount_dir)/*/*/pagecounts-*.gz

## Phony rules to organize things

.PHONY: all clean tsfiles tsfiles-complete tsfiles-incomplete

all: tsfiles

tsfiles: tsfiles-complete tsfiles-incomplete

clean:
	rm -Rf ts ts.mk

dircheck:
	test -d raw -a -d raw/2012 -a -d raw/2012/2012-10


# Rules for generating time series files (generated by Python script below).
# This also builds the tsfiles-complete and tsfiles-incomplete targets.
ifneq ($(MAKECMDGOALS),clean)
  include ts.mk
endif

ts.mk: $(pagecount_files) $(QUACBASE)/bin/wp-ts.mk-create
	mkdir -p ts
	wp-ts.mk-create $(pagecount_dir) > $@
